#Statscan Covid dataset https://www.statcan.gc.ca/eng/covid19
https://www150.statcan.gc.ca/t1/tbl1/en/tv.action?pid=1310076601
library(tidyverse)
library(cansim)
library(cancensus)
library(coxme)
library(ggthemes)
download <- get_cansim( "13-10-0766-01", language = "english", refresh = TRUE, timeout = 900)
names(download) <-str_replace_all(names(download), c(" " = "." , "," = "", "-" = "" ))
Pivoted_data <- download %>%
select(GeoUID, DGUID, Case.identifier.number, Hierarchy.for.Case.information, Case.information, VALUE) %>%
group_by(Case.identifier.number) %>%
pivot_wider(names_from = Case.information, values_from = VALUE)
names(Pivoted_data) <-str_replace_all(names(Pivoted_data), c(" " = "." , "," = "", "-" = "" ))
Pivoted_data
Compress rows *This takes an hour or more to run.
pivoted_empty <- Pivoted_data[1,]
pivoted_empty[1,] <- NA
for(i in unique(Pivoted_data$Case.identifier.number)){
a <- Pivoted_data %>% filter(Case.identifier.number == i)
a[1,5:17] <- diag(as.matrix(a[,-1:-4]))
pivoted_empty <- rbind(pivoted_empty, a[1,])
}
Covid_data <- pivoted_empty[-1,]
Reassign error markers
Covid_data$Gender[which(Covid_data$Gender == 9)] <- NA
Covid_data$Age.group[which(Covid_data$Age.group == 99)] <- NA
Covid_data$Transmission[which(Covid_data$Transmission == 9)] <- NA
Covid_data$Hospitalization[which(Covid_data$Hospitalization == 9)] <- NA
Covid_data$Intensive.care.unit[which(Covid_data$Intensive.care.unit == 9)] <- NA
Covid_data$Death[which(Covid_data$Death == 9)] <- NA
Fix times
Covid_dates <- Covid_data %>% mutate(date = paste("2020", Episode.date..month, Episode.date..day, sep="/")) %>%
mutate(julian = as.numeric(julian(strptime(date,format='%Y/%m/%d'), origin = "2020-01-15 EST")))
Covid_dates
Modify variable names
Covid_data_factors <- Covid_dates %>%
mutate(Gender_factor = case_when(Gender == 1 ~ 'Male',
Gender == 2 ~ 'Female')) %>%
mutate(Transmission_factor = case_when(Transmission == 1 ~ 'Travel',
Transmission == 2 ~ 'Community',
Transmission == 3 ~ "Pending")) %>%
mutate(Hospitalization_factor = case_when(Hospitalization == 1 ~ 'Hospitalized',
Hospitalization == 2 ~ 'Not Hospitalized')) %>%
mutate(ICU_factor = case_when(Intensive.care.unit == 1 ~ 'ICU',
Intensive.care.unit == 2 ~ 'Not ICU')) %>%
mutate(Death_factor = case_when(Intensive.care.unit == 1 ~ 'Dead',
Intensive.care.unit == 2 ~ 'Alive')) %>%
mutate(Age_factor = case_when(Age.group == 1 ~ '0-19',
Age.group == 2 ~ '20-29',
Age.group == 3 ~ '30-39',
Age.group == 4 ~ '40-49',
Age.group == 5 ~ '50-59',
Age.group == 6 ~ '60-69',
Age.group == 7 ~ '70-79',
Age.group == 8 ~ "80+"))
save(Covid_data_factors, file="Covid_data.Rdata")
load(file="Covid_data.Rdata")
Covid_data_factors$julian <- Covid_data_factors$julian + 15
experience_types <- Covid_data_factors %>%
mutate(experience=case_when(
Hospitalization != 1 & Intensive.care.unit != 1 & Death != 1 ~ "FINE",
Hospitalization == 1 & Intensive.care.unit == 1 & Death == 1 ~ "HID",
Hospitalization == 1 & Intensive.care.unit != 1 & Death != 1 ~ "H",
Hospitalization != 1 & Intensive.care.unit == 1 & Death != 1 ~ "I",
Hospitalization != 1 & Intensive.care.unit != 1 & Death == 1 ~ "D",
Hospitalization == 1 & Intensive.care.unit != 1 & Death == 1 ~ "HD",
Hospitalization != 1 & Intensive.care.unit == 1 & Death == 1 ~ "ID",
Hospitalization == 1 & Intensive.care.unit == 1 & Death != 1 ~ "HI"
))
experience_types
ggplot(data=Covid_data_factors, aes(julian)) + geom_density(fill="cornflowerblue", color=NA) +
theme_tufte() +
theme(legend.position = "none") +
scale_x_continuous(limits = c(0,200), breaks = seq(0,150, by=10)) +
#scale_y_continuous(limits = c(0,9), breaks = seq(0,7, by=1), labels = c(0,20,30,40,50,60,70,80)) +
annotate("segment", x = 58, xend = 58, y = 0, yend = 0.024) +
annotate("segment", x = 66, xend = 66, y = 0, yend = 0.022) +
annotate("segment", x = 73, xend = 73, y = 0, yend = 0.020) +
annotate("segment", x = 88, xend = 88, y = 0, yend = 0.018) +
annotate("segment", x = 94, xend = 94, y = 0, yend = 0.016) +
annotate("segment", x = 108, xend = 108, y = 0, yend = 0.014) +
annotate("text", x = 83, y = 0.024, label = "Quebec's first confirmed case") +
annotate("text", x = 77, y = 0.022, label = "'Risk is very low'") +
annotate("text", x = 82, y = 0.020, label = "Close schools") +
annotate("text", x = 112, y = 0.018, label = "Montreal 'State of Emergency'") +
annotate("text", x = 119, y = 0.016, label = "Montreal becomes 'epicenter'") +
annotate("text", x = 142, y = 0.014, label = "Premier takes 'full responsibility’ after") +
annotate("text", x = 146, y = 0.013, label = "‘situation in nursing homes ‘deteriorated’")
Covid_data_factors[which(Covid_data_factors$julian==min(Covid_data_factors$julian, na.rm = T)),]
ggplot(data=Covid_data_factors, aes(Gender_factor)) + geom_bar()+ ylim(0,20000) + theme_tufte()
ggplot(data=Covid_data_factors, aes(Age_factor)) + geom_bar() + theme_tufte()
ggplot(data=Covid_data_factors, aes(Transmission_factor)) + geom_bar()+ ylim(0,25000) + theme_tufte()
ggplot(data=Covid_data_factors, aes(Hospitalization_factor)) + geom_bar()+ ylim(0,20000) + theme_tufte()
ggplot(data=Covid_data_factors, aes(ICU_factor)) + geom_bar()+ ylim(0,20000) + theme_tufte()
ggplot(data=Covid_data_factors, aes(Death_factor)) + geom_bar()+ ylim(0,20000) + theme_tufte()
experience_types %>% select(julian, experience) %>% drop_na() %>% ggplot( aes(x=experience)) + geom_bar(aes(y = (..count..)/sum(..count..))) +
scale_y_continuous(labels = scales::percent, limits = c(0,1))+ theme_tufte()
experience_types %>% select(julian, experience) %>% drop_na() %>% ggplot( aes(x=experience)) + geom_bar(aes(y = (..count..)/sum(..count..))) +
scale_y_continuous(labels = scales::percent, limits = c(0,0.07))+ theme_tufte()
Covid_data_factors %>%filter(Hospitalization ==1 ) %>% ggplot( aes(y = Age.group, x=julian)) + geom_bin2d(binwidth = c(1,1)) + theme_tufte() +xlim(0,130)+ scale_fill_gradient(low = adjustcolor("cornflowerblue", alpha=0.3), high = "firebrick", na.value = NA) +
theme_tufte() + labs(x="Day", y="Age", title="Hospitalizations") +
theme(plot.title = element_text(hjust = 0.5)) +
scale_x_continuous(limits = c(0,150), breaks = seq(0,150, by=10)) +
scale_y_continuous(limits = c(0,9), breaks = c(0,1.4,2.4,3.4,4.4,5.4,6.4,7.4), labels = c(0,20,30,40,50,60,70,80))
Covid_data_factors %>% filter(Intensive.care.unit ==1 ) %>% ggplot( aes(y = Age.group, x=julian)) + geom_bin2d(binwidth = c(1,1)) + theme_tufte()+xlim(0,130)+ scale_fill_gradient(low = adjustcolor("cornflowerblue", alpha=0.3), high = "firebrick", na.value = NA)+
theme_tufte() + labs(x="Day", y="Age", title="ICU admissions") +
theme(plot.title = element_text(hjust = 0.5)) +
scale_x_continuous(limits = c(0,150), breaks = seq(0,150, by=10)) +
scale_y_continuous(limits = c(0,9), breaks = c(0,1.4,2.4,3.4,4.4,5.4,6.4,7.4), labels = c(0,20,30,40,50,60,70,80))
Covid_data_factors %>% filter(Death ==1 ) %>% ggplot( aes(y = Age.group, x=julian)) + geom_bin2d(binwidth = c(1,1)) + theme_tufte()+xlim(0,130) + scale_fill_gradient(low = adjustcolor("cornflowerblue", alpha=0.3), high = "firebrick", na.value = NA)+
theme_tufte() + labs(x="Day", y="Age", title="Deaths") +
theme(plot.title = element_text(hjust = 0.5)) +
scale_x_continuous(limits = c(0,150), breaks = seq(0,150, by=10)) +
scale_y_continuous(limits = c(0,9), breaks = c(0,1.4,2.4,3.4,4.4,5.4,6.4,7.4), labels = c(0,20,30,40,50,60,70,80))
data1 <- Covid_data_factors %>%filter(Hospitalization ==1 )
data2 <- Covid_data_factors %>% filter(Intensive.care.unit ==1 )
data3 <- Covid_data_factors %>% filter(Death ==1 )
notH <- Covid_data_factors %>%filter(Hospitalization ==2 )
ggplot( ) +
stat_density2d(data = data1, aes(y = Age.group, x=julian, alpha=..level..), fill="black", geom = "polygon") +
stat_density2d(data = data2, aes(y = Age.group, x=julian, alpha=..level..), fill="cornflowerblue", geom = "polygon") +
stat_density2d(data = data3, aes(y = Age.group, x=julian, alpha=..level..), fill="firebrick", geom = "polygon") +
theme_tufte() + labs(x="Day", y="Age", title="Hospitalized") +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position = "none") +
annotate("rect", xmin = 0.5, xmax = 10, ymin = 4, ymax = 5, alpha =1, fill="cornflowerblue")+
annotate("rect", xmin = 0.5, xmax = 10, ymin = 2.5, ymax = 3.5, alpha =1, fill="firebrick")+
annotate("rect", xmin = 0.5, xmax = 10, ymin = 1, ymax = 2, alpha =1, fill="grey")+
annotate("text", x = 16, y = 4.5, label = "Deaths") +
annotate("text", x = 15, y = 3, label = "ICU") +
annotate("text", x = 20, y = 1.5, label = "Hospitalization") +
scale_x_continuous(limits = c(0,150), breaks = seq(0,150, by=10)) +
scale_y_continuous(limits = c(0,9), breaks = c(0,1.4,2.4,3.4,4.4,5.4,6.4,7.4), labels = c(0,20,30,40,50,60,70,80))
ggplot( ) +
stat_density2d(data = notH, aes(y = Age.group, x=julian, alpha=..level..), fill="purple", geom = "polygon") +
ylim(1,9) + xlim(0,130) +
theme_tufte() + labs(x="Day", y="Age", title="Not Hospitalized") +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position = "none") +
scale_x_continuous(limits = c(0,150), breaks = seq(0,150, by=10)) +
scale_y_continuous(limits = c(0,9), breaks = c(0,1.4,2.4,3.4,4.4,5.4,6.4,7.4), labels = c(0,20,30,40,50,60,70,80))
ggplot( ) +
stat_density2d(data = notH, aes(y = Age.group, x=julian, alpha=..level..), fill="purple", geom = "polygon") +
stat_density2d(data = data1, aes(y = Age.group, x=julian, alpha=..level..), fill="black", geom = "polygon") +
stat_density2d(data = data2, aes(y = Age.group, x=julian, alpha=..level..), fill="cornflowerblue", geom = "polygon") +
stat_density2d(data = data3, aes(y = Age.group, x=julian, alpha=..level..), fill="firebrick", geom = "polygon") +
theme_tufte() + labs(x="Day", y="Age", title="All outcomes") +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position = "none") +
scale_x_continuous(limits = c(0,150), breaks = seq(0,150, by=10)) +
scale_y_continuous(limits = c(0,9), breaks = c(0,1.4,2.4,3.4,4.4,5.4,6.4,7.4), labels = c(0,20,30,40,50,60,70,80))
Covid_by_travel <- Covid_data_factors %>% filter(Transmission == 1)
Covid_by_community <- Covid_data_factors %>% filter(Transmission == 2)
ggplot( ) +
stat_density2d(data = Covid_by_travel, aes(y = Age.group, x=julian, alpha=..level..), color="limegreen", geom = "polygon")+
ylim(1,9) + xlim(0,130) +
theme_tufte() + labs(x="Day", y="Age", title="Travel transmission") +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position = "none") +
scale_x_continuous(limits = c(0,150), breaks = seq(0,150, by=10)) +
scale_y_continuous(limits = c(0,9), breaks = c(0,1.4,2.4,3.4,4.4,5.4,6.4,7.4), labels = c(0,20,30,40,50,60,70,80))
ggplot( ) +
stat_density2d(data = Covid_by_community, aes(y = Age.group, x=julian, alpha=..level..), color="lightgrey", geom = "polygon")+
ylim(1,9) + xlim(0,130) +
theme_tufte() + labs(x="Day", y="Age", title="Community transmission") +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position = "none") +
scale_x_continuous(limits = c(0,150), breaks = seq(0,150, by=10)) +
scale_y_continuous(limits = c(0,9), breaks = c(0,1.4,2.4,3.4,4.4,5.4,6.4,7.4), labels = c(0,20,30,40,50,60,70,80))
ggplot( ) +
stat_density2d(data = Covid_by_travel, aes(y = Age.group, x=julian, alpha=..level..), color="limegreen", geom = "polygon") +
stat_density2d(data = Covid_by_community, aes(y = Age.group, x=julian, alpha=..level..), color="lightgrey", geom = "polygon") +
theme_tufte() + labs(x="Day", y="Age", title="Travel and community transmission overlay") +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position = "none") +
scale_x_continuous(limits = c(0,150), breaks = seq(0,150, by=10)) +
scale_y_continuous(limits = c(0,9), breaks = c(0,1.4,2.4,3.4,4.4,5.4,6.4,7.4), labels = c(0,20,30,40,50,60,70,80))
data1 <- Covid_by_travel %>%filter(Hospitalization ==1 )
data2 <- Covid_by_travel %>% filter(Intensive.care.unit ==1 )
data3 <- Covid_by_travel %>% filter(Death ==1 )
data4 <- Covid_by_community %>%filter(Hospitalization ==1 )
data5 <- Covid_by_community %>% filter(Intensive.care.unit ==1 )
data6 <- Covid_by_community %>% filter(Death ==1 )
ggplot( ) +
stat_density2d(data = data1, aes(y = Age.group, x=julian, alpha=..level..), color="lightgrey", geom = "polygon") +
stat_density2d(data = data2, aes(y = Age.group, x=julian, alpha=..level..), color="firebrick", geom = "polygon") +
stat_density2d(data = data3, aes(y = Age.group, x=julian, alpha=..level..), color="cornflowerblue", geom = "polygon") +
theme_tufte() + labs(x="Day", y="Age", title="Outcomes from Travel transmission") +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position = "none") +
annotate("rect", xmin = 0.5, xmax = 10, ymin = 4, ymax = 5, alpha =1, fill="cornflowerblue")+
annotate("rect", xmin = 0.5, xmax = 10, ymin = 2.5, ymax = 3.5, alpha =1, fill="firebrick")+
annotate("rect", xmin = 0.5, xmax = 10, ymin = 1, ymax = 2, alpha =1, fill="grey")+
annotate("text", x = 16, y = 4.5, label = "Deaths") +
annotate("text", x = 15, y = 3, label = "ICU") +
annotate("text", x = 20, y = 1.5, label = "Hospitalization") +
scale_x_continuous(limits = c(0,150), breaks = seq(0,150, by=10)) +
scale_y_continuous(limits = c(0,9), breaks = c(0,1.4,2.4,3.4,4.4,5.4,6.4,7.4), labels = c(0,20,30,40,50,60,70,80))
ggplot( ) +
stat_density2d(data = data4, aes(y = Age.group, x=julian, alpha=..level..), color="lightgrey", geom = "polygon") +
stat_density2d(data = data5, aes(y = Age.group, x=julian, alpha=..level..), color="firebrick", geom = "polygon") +
stat_density2d(data = data6, aes(y = Age.group, x=julian, alpha=..level..), color="cornflowerblue", geom = "polygon") +
theme_tufte() + labs(x="Day", y="Age", title="Outcomes from Community transmission") +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position = "none") +
annotate("rect", xmin = 0.5, xmax = 10, ymin = 4, ymax = 5, alpha =1, fill="cornflowerblue")+
annotate("rect", xmin = 0.5, xmax = 10, ymin = 2.5, ymax = 3.5, alpha =1, fill="firebrick")+
annotate("rect", xmin = 0.5, xmax = 10, ymin = 1, ymax = 2, alpha =1, fill="grey")+
annotate("text", x = 16, y = 4.5, label = "Deaths") +
annotate("text", x = 15, y = 3, label = "ICU") +
annotate("text", x = 20, y = 1.5, label = "Hospitalization") +
scale_x_continuous(limits = c(0,150), breaks = seq(0,150, by=10)) +
scale_y_continuous(limits = c(0,9), breaks = c(0,1.4,2.4,3.4,4.4,5.4,6.4,7.4), labels = c(0,20,30,40,50,60,70,80))
ggplot( ) +
stat_density2d(data = data4, aes(y = Age.group, x=julian, alpha=..level..), color="lightgrey", geom = "polygon") +
stat_density2d(data = data5, aes(y = Age.group, x=julian, alpha=..level..), color="firebrick", geom = "polygon") +
stat_density2d(data = data6, aes(y = Age.group, x=julian, alpha=..level..), color="cornflowerblue", geom = "polygon") +
stat_density2d(data = data1, aes(y = Age.group, x=julian, alpha=..level..), color="lightgrey", geom = "polygon") +
stat_density2d(data = data2, aes(y = Age.group, x=julian, alpha=..level..), color="firebrick", geom = "polygon") +
stat_density2d(data = data3, aes(y = Age.group, x=julian, alpha=..level..), color="cornflowerblue", geom = "polygon") +
theme_tufte() + labs(x="Day", y="Age", title="Overlay of outcomes from Community transmission") +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position = "none") +
annotate("rect", xmin = 0.5, xmax = 10, ymin = 4, ymax = 5, alpha =1, fill="cornflowerblue")+
annotate("rect", xmin = 0.5, xmax = 10, ymin = 2.5, ymax = 3.5, alpha =1, fill="firebrick")+
annotate("rect", xmin = 0.5, xmax = 10, ymin = 1, ymax = 2, alpha =1, fill="grey")+
annotate("text", x = 16, y = 4.5, label = "Deaths") +
annotate("text", x = 15, y = 3, label = "ICU") +
annotate("text", x = 20, y = 1.5, label = "Hospitalization") +
scale_x_continuous(limits = c(0,150), breaks = seq(0,150, by=10)) +
scale_y_continuous(limits = c(0,9), breaks = c(0,1.4,2.4,3.4,4.4,5.4,6.4,7.4), labels = c(0,20,30,40,50,60,70,80))
data1 <- Covid_by_travel %>%filter(Hospitalization ==1 & Gender_factor == 'Male')
data2 <- Covid_by_travel %>% filter(Intensive.care.unit ==1 & Gender_factor == 'Male')
data3 <- Covid_by_travel %>% filter(Death ==1 & Gender_factor == 'Male')
data4 <- Covid_by_community %>%filter(Hospitalization ==1 & Gender_factor == 'Male')
data5 <- Covid_by_community %>% filter(Intensive.care.unit ==1 & Gender_factor == 'Male')
data6 <- Covid_by_community %>% filter(Death ==1 & Gender_factor == 'Male')
ggplot( ) +
stat_density2d(data = data1, aes(y = Age.group, x=julian, alpha=..level..), color="lightgrey", geom = "polygon") +
stat_density2d(data = data2, aes(y = Age.group, x=julian, alpha=..level..), color="firebrick", geom = "polygon") +
stat_density2d(data = data3, aes(y = Age.group, x=julian, alpha=..level..), color="cornflowerblue", geom = "polygon") +
theme_tufte() + labs(x="Day", y="Age", title="Outcomes from Travel transmission Males") +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position = "none") +
annotate("rect", xmin = 0.5, xmax = 10, ymin = 4, ymax = 5, alpha =1, fill="cornflowerblue")+
annotate("rect", xmin = 0.5, xmax = 10, ymin = 2.5, ymax = 3.5, alpha =1, fill="firebrick")+
annotate("rect", xmin = 0.5, xmax = 10, ymin = 1, ymax = 2, alpha =1, fill="grey")+
annotate("text", x = 16, y = 4.5, label = "Deaths") +
annotate("text", x = 15, y = 3, label = "ICU") +
annotate("text", x = 20, y = 1.5, label = "Hospitalization") +
scale_x_continuous(limits = c(0,150), breaks = seq(0,150, by=10)) +
scale_y_continuous(limits = c(0,9), breaks = c(0,1.4,2.4,3.4,4.4,5.4,6.4,7.4), labels = c(0,20,30,40,50,60,70,80))
ggplot( ) +
stat_density2d(data = data4, aes(y = Age.group, x=julian, alpha=..level..), color="lightgrey", geom = "polygon") +
stat_density2d(data = data5, aes(y = Age.group, x=julian, alpha=..level..), color="firebrick", geom = "polygon") +
stat_density2d(data = data6, aes(y = Age.group, x=julian, alpha=..level..), color="cornflowerblue", geom = "polygon") +
theme_tufte() + labs(x="Day", y="Age", title="Outcomes from Community transmission Males") +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position = "none") +
annotate("rect", xmin = 0.5, xmax = 10, ymin = 4, ymax = 5, alpha =1, fill="cornflowerblue")+
annotate("rect", xmin = 0.5, xmax = 10, ymin = 2.5, ymax = 3.5, alpha =1, fill="firebrick")+
annotate("rect", xmin = 0.5, xmax = 10, ymin = 1, ymax = 2, alpha =1, fill="grey")+
annotate("text", x = 16, y = 4.5, label = "Deaths") +
annotate("text", x = 15, y = 3, label = "ICU") +
annotate("text", x = 20, y = 1.5, label = "Hospitalization") +
scale_x_continuous(limits = c(0,150), breaks = seq(0,150, by=10)) +
scale_y_continuous(limits = c(0,9), breaks = c(0,1.4,2.4,3.4,4.4,5.4,6.4,7.4), labels = c(0,20,30,40,50,60,70,80))
ggplot( ) +
stat_density2d(data = data4, aes(y = Age.group, x=julian, alpha=..level..), color="lightgrey", geom = "polygon") +
stat_density2d(data = data5, aes(y = Age.group, x=julian, alpha=..level..), color="firebrick", geom = "polygon") +
stat_density2d(data = data6, aes(y = Age.group, x=julian, alpha=..level..), color="cornflowerblue", geom = "polygon") +
stat_density2d(data = data1, aes(y = Age.group, x=julian, alpha=..level..), color="lightgrey", geom = "polygon") +
stat_density2d(data = data2, aes(y = Age.group, x=julian, alpha=..level..), color="firebrick", geom = "polygon") +
stat_density2d(data = data3, aes(y = Age.group, x=julian, alpha=..level..), color="cornflowerblue", geom = "polygon") +
theme_tufte() + labs(x="Day", y="Age", title="Overlay of outcomes from Community transmission Males") +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position = "none") +
annotate("rect", xmin = 0.5, xmax = 10, ymin = 4, ymax = 5, alpha =1, fill="cornflowerblue")+
annotate("rect", xmin = 0.5, xmax = 10, ymin = 2.5, ymax = 3.5, alpha =1, fill="firebrick")+
annotate("rect", xmin = 0.5, xmax = 10, ymin = 1, ymax = 2, alpha =1, fill="grey")+
annotate("text", x = 16, y = 4.5, label = "Deaths") +
annotate("text", x = 15, y = 3, label = "ICU") +
annotate("text", x = 20, y = 1.5, label = "Hospitalization") +
scale_x_continuous(limits = c(0,150), breaks = seq(0,150, by=10)) +
scale_y_continuous(limits = c(0,9), breaks = c(0,1.4,2.4,3.4,4.4,5.4,6.4,7.4), labels = c(0,20,30,40,50,60,70,80))
data1 <- Covid_by_travel %>%filter(Hospitalization ==1 & Gender == 2)
data2 <- Covid_by_travel %>% filter(Intensive.care.unit ==1 & Gender == 2)
data3 <- Covid_by_travel %>% filter(Death ==1 & Gender == 2)
data4 <- Covid_by_community %>%filter(Hospitalization ==1 & Gender == 2)
data5 <- Covid_by_community %>% filter(Intensive.care.unit ==1 & Gender == 2)
data6 <- na.omit(Covid_by_community %>% filter(Death ==1 & Gender == 2))
ggplot( ) +
stat_density2d(data = data1, aes(y = Age.group, x=julian, alpha=..level..), color="lightgrey", geom = "polygon", show.legend = FALSE) +
stat_density2d(data = data2, aes(y = Age.group, x=julian, alpha=..level..), color="firebrick", geom = "polygon", show.legend = FALSE) +
stat_density2d(data = data3, aes(y = Age.group, x=julian, alpha=..level..), color="cornflowerblue", geom = "polygon", show.legend = FALSE) +
theme_tufte() + labs(x="Day", y="Age", title="Outcomes from Travel transmission Females") +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position = "none") +
annotate("rect", xmin = 0.5, xmax = 10, ymin = 4, ymax = 5, alpha =1, fill="cornflowerblue")+
annotate("rect", xmin = 0.5, xmax = 10, ymin = 2.5, ymax = 3.5, alpha =1, fill="firebrick")+
annotate("rect", xmin = 0.5, xmax = 10, ymin = 1, ymax = 2, alpha =1, fill="grey")+
annotate("text", x = 16, y = 4.5, label = "Deaths") +
annotate("text", x = 15, y = 3, label = "ICU") +
annotate("text", x = 20, y = 1.5, label = "Hospitalization") +
scale_x_continuous(limits = c(0,150), breaks = seq(0,150, by=10)) +
scale_y_continuous(limits = c(0,9), breaks = c(0,1.4,2.4,3.4,4.4,5.4,6.4,7.4), labels = c(0,20,30,40,50,60,70,80))
ggplot( ) +
stat_density2d(data = data4, aes(y = Age.group, x=julian, alpha=..level..), color="lightgrey", geom = "polygon", show.legend = FALSE) +
stat_density2d(data = data5, aes(y = Age.group, x=julian, alpha=..level..), color="firebrick", geom = "polygon", show.legend = FALSE) +
stat_density2d(data = data6, aes(y = Age.group, x=julian, alpha=..level..), color="cornflowerblue", geom = "polygon", na.rm = TRUE, show.legend = FALSE) +
theme_tufte() + labs(x="Day", y="Age", title="Outcomes from Community transmission Females") +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position = "none") +
annotate("rect", xmin = 0.5, xmax = 10, ymin = 4, ymax = 5, alpha =1, fill="cornflowerblue")+
annotate("rect", xmin = 0.5, xmax = 10, ymin = 2.5, ymax = 3.5, alpha =1, fill="firebrick")+
annotate("rect", xmin = 0.5, xmax = 10, ymin = 1, ymax = 2, alpha =1, fill="grey")+
annotate("text", x = 16, y = 4.5, label = "Deaths") +
annotate("text", x = 15, y = 3, label = "ICU") +
annotate("text", x = 20, y = 1.5, label = "Hospitalization") +
scale_x_continuous(limits = c(0,150), breaks = seq(0,150, by=10)) +
scale_y_continuous(limits = c(0,9), breaks = c(0,1.4,2.4,3.4,4.4,5.4,6.4,7.4), labels = c(0,20,30,40,50,60,70,80))
ggplot( ) +
stat_density2d(data = data4, aes(y = Age.group, x=julian, alpha=..level..), color="lightgrey", geom = "polygon", show.legend = FALSE) +
stat_density2d(data = data5, aes(y = Age.group, x=julian, alpha=..level..), color="firebrick", geom = "polygon", show.legend = FALSE) +
stat_density2d(data = data6, aes(y = Age.group, x=julian, alpha=..level..), color="cornflowerblue", geom = "polygon", show.legend = FALSE) +
stat_density2d(data = data1, aes(y = Age.group, x=julian, alpha=..level..), color="lightgrey", geom = "polygon", show.legend = FALSE) +
stat_density2d(data = data2, aes(y = Age.group, x=julian, alpha=..level..), color="firebrick", geom = "polygon", show.legend = FALSE) +
stat_density2d(data = data3, aes(y = Age.group, x=julian, alpha=..level..), color="cornflowerblue", geom = "polygon", show.legend = FALSE) +
theme_tufte() + labs(x="Day", y="Age", title="Overlay of outcomes from Community transmission Females") +
theme(plot.title = element_text(hjust = 0.5)) +
theme(legend.position = "none") +
annotate("rect", xmin = 0.5, xmax = 10, ymin = 4, ymax = 5, alpha =1, fill="cornflowerblue")+
annotate("rect", xmin = 0.5, xmax = 10, ymin = 2.5, ymax = 3.5, alpha =1, fill="firebrick")+
annotate("rect", xmin = 0.5, xmax = 10, ymin = 1, ymax = 2, alpha =1, fill="grey")+
annotate("text", x = 16, y = 4.5, label = "Deaths") +
annotate("text", x = 15, y = 3, label = "ICU") +
annotate("text", x = 20, y = 1.5, label = "Hospitalization") +
scale_x_continuous(limits = c(0,150), breaks = seq(0,150, by=10)) +
scale_y_continuous(limits = c(0,9), breaks = c(0,1.4,2.4,3.4,4.4,5.4,6.4,7.4), labels = c(0,20,30,40,50,60,70,80))